//
//  USMainHeaderView.m
//  us
//
//  Created by karry on 2025/4/15.
//

#import "USMainHeaderView.h"
#import "USHeaderDayView.h"

@implementation USMainHeaderView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (void)awakeFromNib{
    [super awakeFromNib];
    
    self.backgroundColor = UIColor.clearColor;
    
    self.lab0.font = [UIFont fontWithName:@"AaJiandaoshitoubuNon-CommercialUse" size:16];
    self.dayLab.font = [UIFont fontWithName:@"AaJiandaoshitoubuNon-CommercialUse" size:16];

    self.titleLab.textColor = UIColor.us_redColor;
    self.titleLab.font = [UIFont fontWithName:@"Pacifico-Regular" size:100];
    
    self.todayLab.hidden = YES;
    self.todayLab.font = [UIFont fontWithName:@"ZenMaruGothic-Bold" size:80];

}

- (void)setDefaultInfoWithName0:(NSString *)name0
                           name1:(NSString *)name1
                anniversaryName:(NSString *)anniversaryName{
    
    NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
    style.lineSpacing = 6; // 设置行间距
    style.alignment = NSTextAlignmentCenter;
    NSDictionary *attrs = @{
        NSParagraphStyleAttributeName: style
    };
    
    NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ ", name0] attributes:attrs];

    NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
    attachment.image = [UIImage imageNamed:@"ic_love"];
    NSAttributedString *iconString = [NSAttributedString attributedStringWithAttachment:attachment];
    [text appendAttributedString:iconString];

    NSMutableAttributedString *text1 = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@" %@", name1] attributes:attrs];
    [text appendAttributedString:text1];
    
    NSString *name = @"在一起";
    if (anniversaryName.length > 0) {
        name = anniversaryName;
    }
    NSAttributedString *together = [[NSAttributedString alloc] initWithString:[@"\n"  stringByAppendingString:name] attributes:attrs];
    [text appendAttributedString:together];

    self.lab0.attributedText = text;
}

- (void)setOtherInfoWithName:(NSString *)name{
    
    NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
    style.lineSpacing = 6; // 设置行间距
    style.alignment = NSTextAlignmentCenter;
    NSDictionary *attrs = @{
        NSParagraphStyleAttributeName: style
    };
    
    NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:name attributes:attrs];

    self.lab0.attributedText = text;
}

- (void)setDay:(NSInteger)day{
    
    NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%ld",day] attributes:@{NSFontAttributeName:[UIFont fontWithName:@"Pacifico-Regular" size:100],NSForegroundColorAttributeName:[UIColor us_redColor]}];
    self.titleLab.attributedText = text;    
}

- (void)setDay:(NSInteger)day
         color:(UIColor *)color {
//    NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%ld",day] attributes:@{NSFontAttributeName:[UIFont fontWithName:@"Pacifico-Regular" size:100],NSForegroundColorAttributeName:color}];
    NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%ld",day] attributes:@{NSFontAttributeName:[UIFont fontWithName:@"Pacifico-Regular" size:100],NSForegroundColorAttributeName:color}];

    
    self.titleLab.attributedText = text;
}
@end
